//
//  ReviewViewController.swift
//  FoodPin
//
//  Created by 王巍 on 16/5/9.
//  Copyright © 2016年 ww. All rights reserved.
//

import UIKit

class ReviewViewController: UIViewController {

    var rating: String?
    
    @IBOutlet var imageView: UIImageView!
    
    @IBOutlet var stackView: UIStackView!
    
    @IBAction func ratingBtnTap(sender: UIButton) {
        
        switch sender.tag {
        case 100:
            rating = "dislike"
            break
        case 200:
            rating = "good"
            break
        case 300:
            rating = "great"
            break
            
        default:
            break
        }
        performSegueWithIdentifier("unwindToDetailView", sender: sender)
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // 可视化特效
        let blurEffectView = UIVisualEffectView(effect: UIBlurEffect(style: .Light))
        blurEffectView.frame = view.frame
        imageView.addSubview(blurEffectView)
        
        // 缩放效果
        let scale = CGAffineTransformMakeScale(0, 0)
        // 位移效果
        let translate = CGAffineTransformMakeTranslation(0, 500)
        
        // stackView.transform = translate
        stackView.transform = CGAffineTransformConcat(scale, translate)
        
    }
    
    override func viewDidAppear(animated: Bool) {
        
         UIView.animateWithDuration(0.3) { () -> Void in
            self.stackView.transform = CGAffineTransformIdentity
        }
 
        
        // 震荡效果
        
        UIView.animateWithDuration(0.3, delay: 0, usingSpringWithDamping: 0.3, initialSpringVelocity: 0.5, options: [], animations: {
                self.stackView.transform = CGAffineTransformIdentity
            }, completion: nil)
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
